/*
 Problem Description
Ignatius is building an Online Judge, now he has worked out all the problems except the Judge System. The system has to read data from correct output file and user's result file, then the system compare the two files. If the two files are absolutly same, then the Judge System return "Accepted", else if the only differences between the two files are spaces(' '), tabs('\t'), or enters('\n'), the Judge System should return "Presentation Error", else the system will return "Wrong Answer".

Given the data of correct output file and the data of user's result file, your task is to determine which result the Judge System will return.
Input
The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
Each test case has two parts, the data of correct output file and the data of the user's result file. Both of them are starts with a single line contains a string "START" and end with a single line contains a string "END", these two strings are not the data. In other words, the data is between the two strings. The data will at most 5000 characters.
Output
For each test cases, you should output the the result Judge System should return.
Sample Input
4
START
1 + 2 = 3
END
START
1+2=3
END
START
1 + 2 = 3
END
START
1 + 2 = 3

END
START
1 + 2 = 3
END
START
1 + 2 = 4
END
START
1 + 2 = 3
END
START
1	+	2	=	3
END
Sample Output
Presentation Error
Presentation Error
Wrong Answer
Presentation Error
 */
package com.yuan.algorithms.practice201505;

import java.util.Scanner;

public class 格式判断 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String str1;
			String str2;
			int n = Integer.parseInt(sc.nextLine());
			while (n-- > 0) {
				str1 = str2 = "";
				// 输入
				if (sc.next().equals("START")) {
					while (true) {
						String s1 = sc.nextLine();
						if (s1.equals("END"))
							break;
						str1 += s1 + "\n";//每接收一行都加上换行符，用来方便判断是否有多的换行
					}
				}
				// 得到用户输出
				if (sc.next().equals("START")) {
					while (true) {
						String s2 = sc.nextLine();
						if (s2.equals("END"))
							break;
						str2 += s2 + "\n";
					}
				}
				//System.out.println(str1 + " " + str2);
				// 比较
				String str = compare(str1, str2);
				if (str.equals("AC")) {
					System.out.println("Accepted");
				} else if (str.equals("WA")) {
					System.out.println("Wrong Answer");
				} else {
					System.out.println("Presentation Error");
				}

			}
		}
	}

	// 比较字符串，返回比较结果
	private static String compare(String str1, String str2) {
		if (str1.equals(str2)) {
			return "AC";
		} else {
			String[] s1 = str1.split("[ \t\n]");//格式化字符串，去除空格、制表符、换行符
			String[] s2 = str2.split("[ \t\n]");
			String ss1 = "", ss2 = "";
			for (int i = 0; i < s1.length; i++) {
				ss1 += s1[i];
				// System.out.println("s1:"+s1[i]);
				// System.out.println("ss1:"+ss1);
			}
			for (int j = 0; j < s2.length; j++) {
				ss2 += s2[j];
				// System.out.println("s2:"+s1[j]);
				// System.out.println("ss2:"+ss2);
			}
			if (!ss1.equals(ss2))//比较格式化后的字符串
				return "WA";
			else
				return "PE";
		}
	}

}
